package com.cooldatasoft.data;

import com.cooldatasoft.service.NumberToTextService;
/**
 * Domain class that hold integer value and its text representation
 * Setting the value from consturctor or setter method will automatically 
 * convert it to its text representation and save in it in the text variable
 * which can be accessed through the getter method.
 * 
 * There is no setter method for text variable as the implementation is hidden
 * from outside world.
 * 
 * @author Fatih Mehmet UCAR - fmucar@gmail.com
 *
 */
public class NumberWord {

	private int value;
	private String text;
	
	/**
	 * Constructor for constructing a NumberWord object from an integer value
	 * @param value Integer value that needs to be converted to text
	 */
	public NumberWord(int value){
		this.value=value;
		this.text=NumberToTextService.getInstance().convertNumberToString(value);
	}
	/**
	 * Getter of value
	 * @return Returns the integer value
	 */
	public int getValue() {
		return value;
	}
	/**
	 * Setter of value
	 * @param Integer value value that needs to be converted to text
	 */
	public void setValue(int value) {
		this.value = value;
		this.text=NumberToTextService.getInstance().convertNumberToString(value);
	}
	/**
	 * getter of text representation of the value passed
	 * @return Text representation of integer value
	 */
	public String getText() {
		return text;
	}
}
